﻿@model LeadMaster.ViewModels.ViewModelReferralData

<h2>
@Model.ReferralCat.Description
</h2>

<div class="spacer"></div>
@using (Html.BeginForm("MaintainItems", "ReferralCats", FormMethod.Post, new { @class = "formMaintainItems" }))
{
    @Html.ValidationSummary(true)
    <fieldset style="border-style: none; width: 500px;">
    @Html.HiddenFor(m => m.ReferralData.ReferralDataID)
    @Html.HiddenFor(m => m.ReferralCatsID)
    @if (ViewBag.ParentReferralDataID!=null)
    {        
    <div>
    <label>Parent Data</label>
    </div>
    <div>
    @Html.DropDownList("ParentReferralDataID", null, new { style = "width:300px;", @class = "chosen" })
    </div>
    <div class="spacer"></div>
    }
    <div>
    <label>Description</label>
    </div>
    <div>
    <textarea rows="5" cols="200" name="ListReferralData" id="ListReferralData">@Model.ListReferralData</textarea>
    </div>
    <div class="spacer"></div>
    <p>
    <input type="submit" value="Save"
    </p>
    </fieldset>
}

<a href="@Url.Action("Index")">Back To List</a>

<script type="text/javascript">
    $(document).ready(function () {

        $(".chosen").chosen();

        $("#ParentReferralDataID").change(function () {
            $.ajax({
                type: "GET",
                url: "@(Url.Action("UpdateParentReferralData","ReferralCats"))/?referralDataID=" + $("#ParentReferralDataID").val() ,
                success: function(data){
                    var ddl = $('#ListReferralData');
                    ddl.empty();
                    $(data).each(function () {
                        ddl.append(this.Text+',')
                    });
                }
            });
          });

              
    });
</script>